#!/usr/bin/env python
# -*- coding:utf-8 -*-
# Create by zhang
# Create on 2022/6/21 17:18
from domain.common.base_dto import BaseDTO
from domain.common.base_schema import BaseSchema
from domain.common.schema_item import SchemaItem
from domain.report.common.period_enum import PeriodEnum


class ProfitDTO(BaseDTO):
    def __init__(self):
        self.stock_id:int = None
        self.stock_code:str = None
        self.year:int = None
        self.period:PeriodEnum = None
        self.is_consolidate: bool = False

        self.total_revenue = None
        self.revenue = None
        self.interest_income = None
        self.prem_earned = None
        self.comm_income = None
        self.total_operating_cost = None
        self.operating_cost = None
        self.interest_fee = None
        self.comm_exp = None
        self.prem_refund = None
        self.compens_payout_refu = None
        self.reser_insur_liab = None
        self.div_payt = None
        self.reins_exp = None
        self.operating_taxes_and_surcharge = None
        self.sales_fee = None
        self.manage_fee = None
        self.financing_expenses = None
        self.assets_impair_loss = None
        self.fv_value_chg_gain = None
        self.invest_income = None
        self.invest_incomes_from_rr = None
        self.financial_assets_measured_at_amplifier_cost_terminal_confirm_income = None
        self.forex_gain = None
        self.reinforcement_of_net_opening_period = None
        self.operate_profit = None
        self.non_operating_income = None
        self.non_operating_payout = None
        self.noncurrent_assets_dispose_remain = None
        self.total_profit = None
        self.income_tax = None
        self.net_profit = None
        self.net_profit_to_p_corp = None
        self.minority_gain = None
        self.basic_eps = None
        self.diluted_eps = None

        self.asset_disposal_income = None
        self.continous_operating_np = None
        self.net_profit_after_nrgal_atsolc = None
        self.net_profit_bi = None
        self.noncurrent_asset_disposal_loss = None
        self.noncurrent_assets_dispose_gain = None
        self.other_income = None
        self.other_comprehensive_income = None
        self.comprehensive_income_to_p_corp = None
        self.dev_cost = None
        self.total_comprehensive_income = None
        self.total_comprehensive_income_to_minority = None
        self.total_comprehensive_income_to_p_corp = None


class ProfitSchema(BaseSchema):
    _schemas = [
        SchemaItem(name="stock_id", title="股票代码(数字)", value_type=str, is_must=True),
        SchemaItem(name="stock_code", title="股票代码（字符串，带交易所简称）", value_type=str, is_must=True),
        SchemaItem(name="stock_name", title="股票名称", value_type=str, is_must=True),
        SchemaItem(name="year", title="年份", value_type=int, is_must=True),
        SchemaItem(name="period", title="报表周期类型", value_type=PeriodEnum, is_must=True),
        SchemaItem(name="is_consolidate", title="是否是合并报表", value_type=bool, is_must=True),

        SchemaItem(name="total_revenue", title="营业总收入", value_type=float, is_must=True),
        SchemaItem(name="revenue", title="营业收入", value_type=float, is_must=True),
        SchemaItem(name="interest_income", title="利息收入", value_type=float, is_must=True),
        SchemaItem(name="prem_earned", title="已赚保费", value_type=float, is_must=True),
        SchemaItem(name="comm_income", title="手续费及佣金收入", value_type=float, is_must=True),

        SchemaItem(name="total_operating_cost", title="营业总成本", value_type=float, is_must=True),
        SchemaItem(name="operating_cost", title="营业成本", value_type=float, is_must=True),
        SchemaItem(name="interest_fee", title="利息支出", value_type=float, is_must=True),
        SchemaItem(name="comm_exp", title="手续费及佣金支出", value_type=float, is_must=True),
        SchemaItem(name="prem_refund", title="退保金", value_type=float, is_must=True),
        SchemaItem(name="compens_payout_refu", title="赔付支出净额", value_type=float, is_must=True),
        SchemaItem(name="reser_insur_liab", title="提取保险合同准备金净额", value_type=float, is_must=True),
        SchemaItem(name="div_payt", title="保单红利支出", value_type=float, is_must=True),
        SchemaItem(name="reins_exp", title="分保费用", value_type=float, is_must=True),
        SchemaItem(name="operating_taxes_and_surcharge", title="营业税金及附加", value_type=float, is_must=True),
        SchemaItem(name="sales_fee", title="销售费用", value_type=float, is_must=True),
        SchemaItem(name="manage_fee", title="管理费用", value_type=float, is_must=True),
        SchemaItem(name="dev_cost", title="研发费用", value_type=float, is_must=True),
        SchemaItem(name="financing_expenses", title="财务费用", value_type=float, is_must=True),
        SchemaItem(name="other_income", title="其他收益", value_type=float, is_must=True),
        SchemaItem(name="invest_income", title="投资收益", value_type=float, is_must=True),
        SchemaItem(name="invest_incomes_from_rr", title="对联营企业和合营企业的投资收益", value_type=float, is_must=True),
        SchemaItem(name="financial_assets_measured_at_amplifier_cost_terminal_confirm_income", title="以摊余成本计量的金融资产终止确认收益", value_type=float, is_must=True),
        SchemaItem(name="forex_gain", title="汇兑收益", value_type=float, is_must=True),
        SchemaItem(name="reinforcement_of_net_opening_period", title="净敞口套期收益", value_type=float, is_must=True),
        SchemaItem(name="fv_value_chg_gain", title="公允价值变动收益", value_type=float, is_must=True),
        SchemaItem(name="credit_impairment_loss", title="信用减值损失", value_type=float, is_must=True),
        SchemaItem(name="assets_impair_loss", title="资产减值损失", value_type=float, is_must=True),
        SchemaItem(name="asset_disposal_income", title="资产处置收益", value_type=float, is_must=True),

        SchemaItem(name="operate_profit", title="营业利润", value_type=float, is_must=True),
        SchemaItem(name="non_operating_income", title="营业外收入", value_type=float, is_must=True),
        SchemaItem(name="non_operating_payout", title="营业外支出", value_type=float, is_must=True),

        SchemaItem(name="total_profit", title="利润总额", value_type=float, is_must=True),
        SchemaItem(name="income_tax", title="所得税费用", value_type=float, is_must=True),

        SchemaItem(name="net_profit", title="净利润", value_type=float, is_must=True),
        SchemaItem(name="continous_operating_np", title="持续经营净利润", value_type=float, is_must=True),
        SchemaItem(name="terminate_net_profit", title="终止经营净利润", value_type=float, is_must=True),
        SchemaItem(name="net_profit_to_p_corp", title="归属于母公司股东的净利润", value_type=float, is_must=True),
        SchemaItem(name="net_profit_to_p_corp", title="归属于母公司所有者的净利润", value_type=float, is_must=True),
        SchemaItem(name="minority_gain", title="少数股东损益", value_type=float, is_must=True),

        SchemaItem(name="other_comprehensive_income_after_tax_net", title="其他综合收益的税后净额", value_type=float, is_must=True),
        SchemaItem(name="other_comprehensive_income_after_tax_net_to_p_corp", title="归属母公司所有者的其他综合收益的税后净额", value_type=float, is_must=True),
        SchemaItem(name="other_comprehensive_income_not_reclassify_in_profit_loss", title="不能重分类进损益的其他综合收益", value_type=float, is_must=True),
        SchemaItem(name="remeasure_beneficiary_plan_change_amount", title="重新计量设定受益计划变动额", value_type=float, is_must=True),
        SchemaItem(name="other_comprehensive_income_not_transfer_under_law", title="权益法下不能转损益的其他综合收益", value_type=float, is_must=True),
        SchemaItem(name="other_equity_instrument_fair_value_changes", title="其他权益工具投资公允价值变动", value_type=float, is_must=True),
        SchemaItem(name="reclassification_other_comprehensive_income", title="将重分类进损益的其他综合收益", value_type=float, is_must=True),
        SchemaItem(name="other_comprehensive_income_transfer_under_law", title="权益法下能转损益的其他综合收益", value_type=float, is_must=True),
        SchemaItem(name="other_bond_fair_value_changes", title="其他债权投资公允价值变动", value_type=float, is_must=True),
        SchemaItem(name="financial_reclassification_in_other_comprehensive_income", title="金融资产重分类计入其他综合收益的金额", value_type=float, is_must=True),
        SchemaItem(name="other_bond_fair_value_changes", title="其他权益工具投资公允价值变动", value_type=float, is_must=True),
        SchemaItem(name="other_creditor_investment_credit_impairment_preparation", title="其他债权投资信用减值准备", value_type=float, is_must=True),
        SchemaItem(name="cash_flow_set_period_reserve", title="现金流量套期储备", value_type=float, is_must=True),
        SchemaItem(name="foreign_currency_financial_statements_conversion_difference", title="外币财务报表折算差额", value_type=float, is_must=True),
        SchemaItem(name="other", title="其他", value_type=float, is_must=True),
        SchemaItem(name="other_total_comprehensive_income_to_minority_after_tax_net", title="归属于少数股东的其他综合收益的税后净额", value_type=float, is_must=True),

        SchemaItem(name="total_comprehensive_income", title="综合收益总额", value_type=float, is_must=True),
        SchemaItem(name="comprehensive_income_to_p_corp", title="归属母公司所有者的综合收益总额", value_type=float, is_must=True),
        SchemaItem(name="total_comprehensive_income_to_minority", title="归属于少数股东的综合收益总额", value_type=float, is_must=True),

        SchemaItem(name="other_comprehensive_income", title="其他综合收益", value_type=float, is_must=True),

        SchemaItem(name="basic_eps", title="基本每股收益(元/股)", value_type=float, is_must=True),
        SchemaItem(name="diluted_eps", title="稀释每股收益(元/股)", value_type=float, is_must=True),

        # 未分类
        SchemaItem(name="noncurrent_assets_dispose_remain", title="非流动资产处置净损失", value_type=float, is_must=True),
        SchemaItem(name="net_profit_after_nrgal_atsolc", title="扣除非经常性损益后的净利润", value_type=float, is_must=True),
        SchemaItem(name="net_profit_bi", title="净利润差额(合计平衡项目)", value_type=float, is_must=True),
        SchemaItem(name="noncurrent_asset_disposal_loss", title="非流动资产处置损失", value_type=float, is_must=True),
        SchemaItem(name="noncurrent_assets_dispose_gain", title="非流动资产处置利得", value_type=float, is_must=True),

        SchemaItem(name="total_comprehensive_income_to_minority", title="归属于少数股东的综合收益总额", value_type=float, is_must=True),
        SchemaItem(name="total_comprehensive_income_to_p_corp", title="归属于母公司股东的综合收益总额", value_type=float, is_must=True)
    ]

    _name2schema = {}

    _title2name = {}